<template>
  <div class="comdiv">
    <div class="con" ref="bgImage">
    <el-table :data="list" v-loading.body="listLoading" border fit highlight-current-row style="width: 100%">
      <el-table-column align="center" label="序号" >
        <template slot-scope="scope"><span>{{scope.row.px}}</span></template>
      </el-table-column>
      <el-table-column align="center" label="流程名">
        <template slot-scope="scope"><span>{{scope.row.groupName}}</span></template>
      </el-table-column>
      <el-table-column align="center" label="流程id">
        <template slot-scope="scope"><span>{{scope.row._id}}</span></template>
      </el-table-column>
      <el-table-column align="center" label="备注">
        <template slot-scope="scope"><span>{{scope.row.remark}}</span></template>
      </el-table-column>
      <el-table-column align="center" label="流程状态操作">
        <template slot-scope="scope" ><span>
          <el-button type="primary" plain @click="showFlow(scope.row)" size="small">编辑</el-button>
<!--          <el-steps :active="2" align-center >
            <el-step title="申请设置" @click.native="showFlow(1)" description="" ></el-step>
            <el-step title="审核设置" @click.native="showFlow(2)" description=""></el-step>
            <el-step title="结束"  description=""></el-step>
          </el-steps>-->

        </span></template>
      </el-table-column>
    </el-table>



    <!--权限展示-->
    <el-dialog title="角色权限" :visible.sync="dialogFormVisible2">
      <el-tabs v-model="activeName" @tab-click="">
        <el-tab-pane label="用户管理" name="first">

          <el-checkbox-group v-model="form.type">
            <el-checkbox label="添加用户" name="type"></el-checkbox>
            <el-checkbox label="修改用户" name="type"></el-checkbox>
            <el-checkbox label="审核用户" name="type"></el-checkbox>
            <el-checkbox label="删除用户" name="type"></el-checkbox>                <el-checkbox label="添加用户" name="type"></el-checkbox>
            <el-checkbox label="修改用户" name="type"></el-checkbox>
            <el-checkbox label="审核用户" name="type"></el-checkbox>
            <el-checkbox label="删除用户" name="type"></el-checkbox>                <el-checkbox label="添加用户" name="type"></el-checkbox>
            <el-checkbox label="修改用户" name="type"></el-checkbox>
            <el-checkbox label="审核用户" name="type"></el-checkbox>
            <el-checkbox label="删除用户" name="type"></el-checkbox>                <el-checkbox label="添加用户" name="type"></el-checkbox>
            <el-checkbox label="修改用户" name="type"></el-checkbox>
            <el-checkbox label="审核用户" name="type"></el-checkbox>
            <el-checkbox label="删除用户" name="type"></el-checkbox>                <el-checkbox label="添加用户" name="type"></el-checkbox>
            <el-checkbox label="修改用户" name="type"></el-checkbox>
            <el-checkbox label="审核用户" name="type"></el-checkbox>
            <el-checkbox label="删除用户" name="type"></el-checkbox>
          </el-checkbox-group>
        </el-tab-pane>
        <el-tab-pane label="配置管理" name="second">配置管理</el-tab-pane>
        <el-tab-pane label="角色管理" name="third">角色管理</el-tab-pane>
      </el-tabs>
    </el-dialog>

    <!--流程图展示-->
    <flowedit ref="edit"
      :row="row"
    ></flowedit>
  </div>
</div>
</template>

<script>

  /* eslint-disable */
  import { fetchGet,createOne,deleteOne,getOne,rolesAll,updateOneNoId } from '@/api/common'
  import { disableBtn,df,$err,$suc,ERRS,SUCS } from '@/utils'
  import flowedit from './comp/flowEdit'
  export default {
    name: 'roleList',
    // search2 引入 and search3 声明
    components: {flowedit},

    data() {
      return {
        list: null,
        px: null, //最大序号
        listLoading: true,
        listQuery: {
          searchText:undefined,
        },
        row:{},
        //弹出层
        dialogFormVisible: false,
        //权限弹出层
        dialogFormVisible2: false,
        activeName: 'first',
        form: {
          type: [],
        },
        //流程图弹出层
        textMap2: {
          1: '指定申请人',
          2: '指定审核人'
        },
        dialogStatus: '',
        textMap: {
          update: '编辑角色',
          create: '添加角色'
        },
        temp: {
          id: undefined,
          roleName:'',
          roleCode:'',
          rangeList:'',
          changeList:'',
        },
        template: {
          id: undefined,
          roleName:'',
          roleCode:''
        },
        rules: {
          roleName: [
            { required: true, message: '请输入角色名', trigger: 'blur' }
          ],
          roleCode: [
            {required: true, message: '请输入标记名', trigger: 'change'},
          ]
        }
      }
    },
    mounted() {
      this.getList();
      this.initInfo();
    },
    methods: {
      showFlow(row){
        this.$refs.edit.getNodeInfo(row)
      },

      ////search5
      handleFilter(val) {
        this.listQuery.searchText=val;
        this.getList()
      },

      getList() {

        fetchGet(`flowable/dy/all`).then(res => {
          console.log(res);
          if (res.code == 0) {
            let dat = res.data
            this.list = dat;
            this.list = this.list.map((v, index) => {
              this.$set(v, 'px', index + 1);
              return v
            });

            this.$nextTick()
          } else {
            ERRS(res.message)
          }
          this.listLoading = false
        })

      },

      //加载公司下拉列表信息
      initInfo(){

      },
      resetTemp() {
        this.temp = this.template;
      },

      /* -------         curd        ---------- */
      //添加
      handleCreate() {
        this.resetTemp();
        this.dialogStatus = 'create'
        this.dialogFormVisible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].clearValidate()
        })
      },

      handleResource(){
        this.dialogFormVisible2 = true;
      },
      //详情修改
      handleUpdate(row) {
        console.log(row.id);
        this.temp=row;
        this.dialogFormVisible = true;
        this.$nextTick(() => {
          this.$refs['dataForm'].clearValidate()
        })
      },
      //修改提交
      updateData() {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            disableBtn('cfmbtm2');
            // delete tempData.createdTime;
            updateOneNoId(this.url,this.temp).then(response => {
              this.getList();
              this.dialogFormVisible = false
            })
          }
        })
      },
      //删除
      handleDelete(row, status) {
        this.$msgbox({
          // title: '删除',
          message: '确定要删除吗?',
          showCancelButton: true,
          confirmButtonText: '确定',
          cancelButtonText: '取消'
        }).then(action => {
          deleteOne(this.url,{id:row.id}).then(res => {
            df(5435345,res)
            return
            this.getList();
            this.dialogFormVisible = false
            succ('删除成功')
          })
        });
      },

    }
  }
</script>

<style >
  .comdiv {
    padding: 10px 5px 5px 5px;
    width: 100%;
    height: 100%;
  }
  .edit-input {
    padding-right: 100px;
  }
  .cancel-btn {
    position: absolute;
    right: 15px;
    top: 13px;
  }

  .el-checkbox {
    margin-left: 30px;
  }
  .el-step__head:hover {
    color: #67c23a;
    border-color: #67c23a;
    cursor: pointer;
  }
</style>
